PATHMac OS 8 and 9 Developer Documentation > Networking and Communications > URL Access Manager >

Transferring Files With the URL Access Manager


Notification Callback Routine

When you call URLOpen , you may want to specify a notification callback routine to receive information about events that occur during an asynchronous download or upload. This is how you would declare the callback function if you were to name the function MyURLNotifyProc :

OSStatus *MyURLNotifyProcPtr (
                     void* userContext,
                     URLEvent event,
                     URLCallbackInfo *callbackInfo);
userContext
An application-defined value that your application previously passed as a parameter when it called URLOpen . When an event occurs, the URL Access Manager passes userContext back to you.
event
A value of type URLEvent specifying the event that triggered the callback. The type of event that can trigger a callback depends on whether you called URLOpen with a fileSpec that is a valid file specificiation. See the discussion section for details.
callbackInfo
A pointer to a structure of type URLCallbackInfo . On return, this structure contains information relevant to the event that has occurred.
result
Your notification callback routine should always return noErr .

DISCUSSION

The URL Access Manager will call your notification callback routine when events for which your application has registered occur during the asynchronous download or upload of data to a URL. Use the eventRegister parameter to the URLOpen function to specify the events for which you want to receive notification.

If you call URLOpen with a fileSpec parameter that is a valid file specification, the following events can cause the URL Access Manager to call your application's notification callback routine:

kURLPercentEvent kURLPeriodicEvent kURLPropertyChangedEvent kURLSystemEvent kURLInitiatedEvent kURLResourceFoundEvent kURLDownloadingEvent kURLUploadingEvent kURLAbortInitiatedEvent kURLCompletedEvent kURLErrorOccurredEvent

If you call URLOpen with a fileSpec parameter that is NULL and you are downloading from a URL, the following events can cause the URL Access Manager to call your application's notification callback routine:

kURLDataAvailableEvent kURLTransactionCompleteEvent

See Event Constants for a description of each constant.

WARNING

Do not call URLDisposeReference from your notification callback routine. Doing so may cause your application to stop working. Other than this restriction, your application can make any call. For example, your notification callback routine can update its human interface, allocate and deallocate memory, or call NewThread ..


© 1999 Apple Computer, Inc. – (Last Updated 07 May 99)